<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>04-添加class.html</title>
	<style>
		*{
			margin: 0;
			padding: 0;
		}
		div{
			width: 100px;
			height: 100px;
			border: 1px solid #000;
		}
		.box{
			background: red;
			font-size: 24px;
		}
	</style>
</head>
<body>
	<input type="button" value="添加class" onclick="document.getElementById('box').className='box'">
	<div id="box">这是文字</div>
</body>
</html>